﻿using NewAndong.Comm;
using NewAndong.Handle;
using System;
using System.Data;
using System.Linq;
using System.Windows.Forms;

namespace NewAndong.Forms
{
    public partial class FrmLedOperatoin : Form
    {
        NewAndongHandler NewAndongHandler;
        string _Name;
        public FrmLedOperatoin(string name)
        {
            InitializeComponent();
            _Name = name;
            uiPanel1.Text =$"打开或关闭安东屏({_Name})" ;
        }

        private void FrmLedOperatoin_Load(object sender, EventArgs e)
        {
            NewAndongHandler = NewAndongHandler.CreateInstance();
        }

        private void btnClose_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void btnCancel_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void btnLedClose_Click(object sender, EventArgs e)
        {
            var device = GolbalVariable.SystemDeviceBag.Where(x => x.DataSource == "LED" && x.DeviceName == _Name).FirstOrDefault();
            NewAndongHandler.CloseLed(device,true);
        }

        private void btnLedOpen_Click(object sender, EventArgs e)
        {
            var device = GolbalVariable.SystemDeviceBag.Where(x => x.DataSource == "LED" && x.DeviceName == _Name).FirstOrDefault();
            NewAndongHandler.OpenLed(device, true);
        }
    }
}
